home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / DTSCPlusLibrary / Sources / Environment.cp < prev    next >
Encoding:
Text File  |  1993-01-14  |  3.1 KB  |  117 lines  |  [TEXT/MPS ]

  1. /* _________________________________________________________________________________________________________ //
  2.   Copyright © 1992 Apple Computer, Inc. All rights reserved.
  3.   Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
  4.   Programmer: Kent Sandvik
  5.   Date: 11/9/92
  6.   Revision comments are at the end of this file.
  7.   ---
  8.   TEnvironment is a Gestalt wrapper class that finds out information about the environment.
  9.   Environment.cp contains the member functions for the TEnvironment class.
  10.   _________________________________________________________________________________________________________ */
  11.  
  12. // INCLUDES
  13. #ifndef _ENVIRONMENT_
  14. #include "Environment.h"
  15. #endif
  16.  
  17.  
  18. // _________________________________________________________________________________________________________ //
  19. // TEnvironment class member function implementations
  20.  
  21. //    CONSTRUCTORS & DESTRUCTORS
  22. #pragma segment Environment
  23. TEnvironment::TEnvironment()
  24. {
  25.     // Set fields to known values.
  26.     fResult = false;
  27.     fLongResult = 0L;
  28. }
  29.  
  30. #pragma segment Environment
  31. TEnvironment::~TEnvironment()
  32. {
  33.  
  34. }
  35.  
  36.  
  37. //    MAIN INTERFACE
  38.  
  39. #pragma segment Environment
  40. Boolean TEnvironment::HasAttribute(OSType attribute,
  41.                                    short theBit)
  42. // Generic test that takes the Gestalt attribute and the bit value, and returns a Boolean.
  43. {
  44.     return (::Gestalt(attribute, &fLongResult) == noErr) && (((fLongResult >> theBit) & 1) != 0);
  45. }
  46.  
  47.  
  48. #pragma segment Environment
  49. Boolean TEnvironment::Check128k()
  50. // Checks if we are running under a 128k or better ROM.
  51. {
  52.     // check if 128k ROM Macintosh or not - the framework will not work properly
  53.     // on 64k ROM systems...
  54.  
  55.     SysEnvRec envRec;
  56.  
  57.     // ignore the error returned from SysEnvirons; even if an error occurred,
  58.     // the SysEnvirons glue will fill in the SysEnvRec
  59.     (void)::SysEnvirons(curSysEnvVers, &envRec);
  60.  
  61.     if (envRec.machineType < 0)                    // are we running on a 128K ROM machine or better???
  62.         return false;                            // we don't have a 128k System
  63.     else
  64.         return true;                            // we have a 128k System or better
  65. }
  66.  
  67.  
  68. #pragma segment Environment
  69. Boolean TEnvironment::HasAppleEvents()
  70. // Check if we have Apple Events support or not.
  71. {
  72.     fResult = (::Gestalt(gestaltAppleEventsAttr, &fLongResult) == noErr);
  73.     return fResult;
  74. }
  75.  
  76.  
  77. #pragma segment Environment
  78. Boolean TEnvironment::HasColorQD()
  79. // Check if we have Color QuickDraw support or not.
  80. {
  81.     fResult = (::Gestalt(gestaltQuickdrawFeatures, &fLongResult) == noErr);
  82.     return fResult;
  83. }
  84.  
  85.  
  86. #pragma segment Environment
  87. Boolean TEnvironment::IsSystemSeven()
  88. // Check if we are running on a System 7 version.
  89. {
  90.     ::Gestalt(gestaltSystemVersion, &fLongResult);// check for system version
  91.  
  92.     if (fLongResult >= 0x0700)
  93.         return true;
  94.     else
  95.         return false;
  96. }
  97.  
  98.  
  99. #pragma segment Environment
  100. Boolean TEnvironment::TrapAvailable(short aNumber,
  101.                                     TrapType aType)
  102. // Check if the trap is implemented or not.
  103. {
  104.     // Return true if trap is available
  105.     return (::NGetTrapAddress(aNumber, aType) != GetTrapAddress(_Unimplemented));
  106. }
  107.  
  108.  
  109. // _________________________________________________________________________________________________________ //
  110.  
  111.  
  112. /*    Change History (most recent last):
  113.   No        Init.    Date        Comment
  114.   1            khs        11/9/92        New file
  115. */
  116.  
  117.